package com.guangyunl.h_polymorphic;
// 多态扩展性
public class Test10 {
    public static void main(String[] args) {
        /*
        double b = 10;
        b = 100L;
         */

        Animal animal = new Dog();
        animal.eat();

        animal = new Cat();
        animal.eat();
        System.out.println("======================");

        Dog dog = new Dog();
        method(dog);
        System.out.println("======================");

        Cat cat = new Cat();
        method(cat);
        System.out.println("======================");

    }

    /*
    形参传递父类类型，调用此方法父类类型可以接收任意它的子类对象
    传递哪个子类对象，就指向哪个子类对象，就调用哪个子类对象重写的方法
     */
    public static void method(Animal animal){ // Animal animal = dog  Animal animal = cat
        animal.eat();
    }
}
/*
狗啃骨头
猫吃鱼
======================
狗啃骨头
======================
猫吃鱼
======================
 */